﻿using System;
using System.Collections.Generic;
using SinBiota.Model.Business.PersistenceServices.Interfaces;
using SinBiota.Model.Entities;
using SinBiota.Model.Persistence.Repositories.Interfaces;

namespace SinBiota.Model.Business.PersistenceServices.Implementation
{
    public class MethodPersistenceServices : IMethodPersistenceServices
    {
        private readonly IMethodRepository _methodRepository;

        public MethodPersistenceServices(IMethodRepository methodRepository)
        {
            _methodRepository = methodRepository;
        }

        public Method FindById(int id)
        {
            return _methodRepository.FindById(id);
        }

        public Method FindByName(string name)
        {
            return _methodRepository.FindByName(name);
        }


        public IList<Method> FindAll()
        {
            return _methodRepository.FindAll();
        }

        public void Delete(Method method)
        {
            _methodRepository.Delete(method);
        }

        public void DeleteById(int id)
        {
            Delete(FindById(id));
        }
        public void Save(Method method)
        {
            _methodRepository.Save(method);
        }

        public void Update(Method method)
        {
            _methodRepository.Update(method);
        }

        public IList<Method> FindByNameLike(string s)
        {
            return _methodRepository.FindByInffix(method => method.Name, s);
        }
    }
}